home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmigaPlus / AmigaOS / SDL_Teil1 / SDL1 / zweites.c < prev   
Encoding:
C/C++ Source or Header  |  2003-02-23  |  1.2 KB  |  51 lines

  1. #include <stdlib.h>
  2. #include "SDL.h"
  3.  
  4. int main()
  5. {
  6.   /* reserviere datenstrukturen für Video*/
  7.   SDL_Surface *display;
  8.   SDL_Surface *image;
  9.   int vm;
  10.  
  11.   /* initialisiere SDL */
  12.   if (SDL_Init(SDL_INIT_VIDEO) < 0)
  13.   {
  14.     printf("SDL konnte nicht initialisiert werden: %s\n", SDL_GetError());
  15.     exit(-1);
  16.   }
  17.   printf("SDL erfolgreich initialisiert!\n");
  18.  
  19.   /* lege Bildschirmgröße fest */
  20.   vm = SDL_VideoModeOK(640, 512, 8, SDL_HWSURFACE);
  21.   if (vm == 0) vm = SDL_VideoModeOK(640, 512, 8, SDL_SWSURFACE);
  22.   printf("mögliche Farbtiefe: %d\n", vm);
  23.   if (vm > 0)
  24.   {
  25.     display = SDL_SetVideoMode(640, 512, vm, SDL_SWSURFACE);
  26.   }
  27.   else
  28.   {
  29.     printf("Konnte kein Display der Auflösung 640 x 512 öffnen: %s\n", SDL_GetError());
  30.     exit(-1);
  31.   }
  32.  
  33.   /* lade Bild in SDL_Surface */
  34.   image = SDL_LoadBMP("SDL_Title.bmp");
  35.   if (image == NULL)
  36.   {
  37.     printf("Konnte Bild nicht laden: %s\n",  SDL_GetError());
  38.   }
  39.  
  40.  
  41.   /* zeige Bild an */
  42.   SDL_BlitSurface(image, NULL, display, NULL);
  43.   SDL_Flip(display);
  44.   SDL_Delay(3000);
  45.  
  46.   /* räume SDL auf */
  47.   SDL_FreeSurface(image);
  48.   printf("Verlasse SDL...\n");
  49.   atexit(SDL_Quit);
  50. }
  51.